package com.digua.baseiot.base

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.blankj.utilcode.util.NetworkUtils
import com.blankj.utilcode.util.NetworkUtils.OnNetworkStatusChangedListener
import com.digua.base.base.Activity
import com.digua.baseiot.MyApp

open class BaseActivity<UI : ViewBinding> : Activity<UI>(), OnNetworkStatusChangedListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MyApp.instance.addActivity(this)
        NetworkUtils.registerNetworkStatusChangedListener(this)
    }

    override fun onDestroy() {
        NetworkUtils.registerNetworkStatusChangedListener(this)
        MyApp.instance.colse(this::class.java)
        super.onDestroy()
    }

    /**
     * 网络断开
     */
    override fun onDisconnected() {}

    /**
     * 网络连接
     */
    override fun onConnected(networkType: NetworkUtils.NetworkType) {}
}